package ca.seia.comp6521.a1.memory;

import java.io.IOException;
import java.util.LinkedList;

import ca.seia.comp6521.a1.io.DataFileWriter;

public class OutputMemoryBuffer extends MemoryBuffer {

	DataFileWriter writer;
	
	public OutputMemoryBuffer(int capacity)
	{
		super(capacity);
	}
	
	public OutputMemoryBuffer(String assignedSublistFile, int capacity) throws IOException {
		super(assignedSublistFile, capacity);
		this.writer = new DataFileWriter(this.assignedSublistFile);
	}
	
	
	public void write() throws IOException{
		this.writer.writeNextIntegers((LinkedList<Integer>) this.buffer);
		this.buffer.clear();
	}
	
	public void setAssignedSublistFile(String assignedSublistFile) throws IOException {
		this.buffer.clear();
		this.assignedSublistFile = assignedSublistFile;
		this.writer = new DataFileWriter(assignedSublistFile);
	}
	
}
